'use strict';

import sharp from 'sharp'
import { notFound } from 'next/navigation'

import DesignConfigurator from './DesignConfigurator'

interface PageProps {
  searchParams: {
    [key: string]: string | string[] | undefined
  }
}


const Page = async ({ searchParams }: PageProps) => {
  // 获取Id 取图片
  const { id } = searchParams
  if (!id || typeof id !== 'string') {
    return notFound()
  }

  const pathImg = `./public/horse_phone.jpg`
  const imgMetadata = await sharp(pathImg).metadata()
  const { height, width } = await imgMetadata 
  const imageUrl = '/horse_phone.jpg'
  console.log(height, width);
  
  return <DesignConfigurator imageUrl={imageUrl} imageDimensions={{height, width}} />
}

export default Page